<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        const p1 = new Promise((resolve, reject) => {
            console.log("数据请求中");

            try {

                throw new Error("网络错误！")

                setTimeout(() => {
                    console.log("数据请求成功");
                    resolve("成功！")
                }, 3000)

            } catch (e) {
                console.log(e); //e  接收的错误对象
                console.log(e.message); //e上有一个message属性,就是当前错误的信息
                reject(e.message) //改变Promise状态为失败，显示错误的信息
            }
        })


        console.log("p1", p1);
    </script>
</body>

</html>